home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: in1.uu.net!allegra!alice!ark
- From: ark@research.att.com (Andrew Koenig)
- Subject: Re: Destructors in functions
- Message-ID: <DL57qo.ICn@research.att.com>
- Organization: AT&T Bell Laboratories, Murray Hill NJ
- References: <4d7r65$dv9@newsbf02.news.aol.com>
- Date: Sat, 13 Jan 1996 23:25:35 GMT
-
- In article <4d7r65$dv9@newsbf02.news.aol.com> weatby@aol.com (Weatby) writes:
-
- > If you pass an object to a function, the language makes a bitwise copy of
- > it, local to the function. (Assuming no copy constructor is defined.)
- > Then, on the way out, the function calls the user-defined constructor.
-
- Not quite true. If you don't define a copy constructor, copying an
- object of that class is equivalent to copying its elements (which may
- have their own copy constructors).
-
- If your class has a non-empty destructor, it should have an explicit
- copy constructor and assignment operator. It is possible to imagine
- exceptions to that rule, but they are rare.
- --
- --Andrew Koenig
- ark@research.att.com
-